function ipBlock(req, res, next) {
  if (!isIpBlock) return next()

  const ipList = ['222.71.104.95', '127.0.0.1']
  const currentIp = (
    req.headers['x-forwarded-for'] ||
    req.connection.remoteAddress ||
    req.socket.remoteAddress ||
    req.connection.socket.remoteAddress
  ).split(',')[0]
  if (ipList.includes(currentIp)) {
    next()
  } else {
    res.json({
      success: true,
      mode: 'ip block'
    })
  }
}

module.exports = ipBlock
